<?php
class Application_Model_city extends Application_Model_DomainObject{
	
        protected $_id;//序号
        protected $_continent;//洲
        protected $_areaCode;//        
        protected $_country;//所属国家
        protected $_name;//名称
        protected $_parentId;//父ID
        protected $_type;//类型
        protected $_ename;//英文名
        protected $_serviceFee;//服务费
        protected $_sortid;//排序号
        protected $_percent;//服务费百分比
        protected $_state;//状态
        protected $_default;//默认值
        protected $_hot;//热点城市
        protected $_sortcode;//城市代码
        
        protected $_word;
        
        /**
         * 是否欧盟
         */
        public function isEuro(){
            return $this->_areaCode >=7 && $this->_areaCode <=10;
        }


        /*
         * 根据国家名称获取城市列表
         */
        public static function   getbycountry($country){        
            $getItem=new Application_Model_DbTable_city();
            return $getItem->getbycountry($country);
        }
        
        /*
         * 根据上级序号查询
         */
        public static function  GetByParentId($ParentID,$returnType){
            $getItem=new Application_Model_DbTable_city();
            return $getItem->GetByParentId($ParentID,$returnType);
        }
        
        /*
         * 获取热门城市信息
         */
        public static function  GetByhot($parentId=0)
        {
            $getItem=new Application_Model_DbTable_city();
            return $getItem->GetByhot($parentId);
        }
        
        /*
         * 根据第一个字母查找城市
         */
        public  static function  GetBySortCode($code,$parentId=0)
        {
            $getItem=new Application_Model_DbTable_city();
            return $getItem->GetBySortCode($code,$parentId);
        }
        
        public static function getByName($city){
            return  Application_Model_city::getDao()->queryOne(array('name'=>$city));
        }
        public function getUserCity($cityid)
        {
            $where = array();
            if( $cityid != '')$where[' id = '] = $cityid;
            $getItem = new Application_Model_DbTable_city();
            $result = $getItem->queryOne($where);
            return $result;
        }
        
        public static function byAllcity()
        {
            return Application_Model_city::getDao()->queryAll(array(),"state desc");
        }
        
        public static function getByWord($word)
        {
            return  Application_Model_city::getDao()->queryOne(array('word' => $word));
        }
}